<%@page import="bean.FmBoardVo"%>
<%@page import="java.util.ArrayList"%>
<%@page import="bean.FmBoardDTO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel = 'stylesheet' href='./FmBoard/Board.css'/>
<script src='./FmBoard/Board.js'></script>
</head>
<body>



<jsp:useBean id="vo" class="bean.FmBoardVo" scope="page"></jsp:useBean>
<jsp:setProperty property="*" name="vo"/>


<%
FmBoardDTO dto = new FmBoardDTO();
dto.setVo(vo);
ArrayList<FmBoardVo> al = dto.select();
String m="";
if(session.getAttribute("sessionMid")!=null){
	m = (String)session.getAttribute("sessionMid");
}
%>

<form name='hiddenFrm' method='post'>
	<input type='hidden' name='nowPage' value='<%=vo.getNowPage()%>'/>
	<input type='hidden' name='kindFind' value='<%=vo.getKindFind()%>'/>
	<input type='hidden' name='locateFind' value='<%=vo.getLocateFind()%>'/>
	<input type='hidden' name='genderFind' value='<%=vo.getGenderFind()%>'/>
	<input type='hidden' name='find' value='<%=vo.getFind()%>'/>
	<input type='hidden' name='rno' value='<%=vo.getRno()%>'/>
	<input type='hidden' id='smid' value='<%=m %>'/>
</form>

<h1 align = 'center'><a href = "index.jsp?inc=./FmBoard/bList.jsp">나를 찾아줘</a></h1><hr/><p/>
<%System.out.println("kf="+vo.getKindFind()); %>
<div id='board_list_find'>
	<form name='board_list_frm' method='post'
		action='index.jsp?inc=./FmBoard/bList.jsp'>
		<select name='kindFind' size='1'>
			<option value='' <% if(vo.getKindFind()==null){ %> selected="selected" <%} %>>품종</option>
			<option value='강아지' <%if(vo.getKindFind().equals("강아지")){ %> selected="selected" <%} %>>강아지</option>
			<option value='고양이' <% if(vo.getKindFind().equals("고양이")){ %> selected="selected" <%} %>>고양이</option>
			<option value='페릿' <% if(vo.getKindFind().equals("페릿")){ %> selected="selected" <%} %>>페릿</option>
			<option value='호랑이' <% if(vo.getKindFind().equals("호랑이")){ %> selected="selected" <%} %>>호랑이</option>
			<option value='팬더' <% if(vo.getKindFind().equals("팬더")){ %> selected="selected" <%} %>>팬더</option></select>
		<select name='locateFind' size='1'>
			<option value='' <% if(vo.getLocateFind()==null){ %> selected="selected" <%} %>>지역</option>
			<option value='서울시' <% if(vo.getLocateFind().equals("서울시")){ %> selected="selected" <%} %>>서울시</option>
			<option value='경상도' <% if(vo.getLocateFind().equals("경상도")){ %> selected="selected" <%} %>>경상도</option>
			<option value='전라도' <% if(vo.getLocateFind().equals("전라도")){ %> selected="selected" <%} %>>전라도</option>
			<option value='강원도' <% if(vo.getLocateFind().equals("강원도")){ %> selected="selected" <%} %>>강원도</option>
			<option value='함경도' <% if(vo.getLocateFind().equals("함경도")){ %> selected="selected" <%} %>>함경도</option></select>
		<select name='genderFind' size='1'>
			<option value='' <% if(vo.getGenderFind()==null){ %> selected="selected" <%} %>>성별</option>
			<option value='남아' <% if(vo.getGenderFind().equals("남아")){ %> selected="selected" <%} %>>남아</option>
			<option value='여아' <% if(vo.getGenderFind().equals("여아")){ %> selected="selected" <%} %>>여아</option></select>
		<input type='text' name='find'/>
		
		
		<input type='submit' value='검색'/>
	</form>
</div>





<input type='button' value='게시물 등록' id='btnInput' />
<p/><p/>

<div id='board_list_title'>
	<div class='board_list_rno'>글번호</div>
	<div class='board_list_pic'>사진</div>
	<div class='board_list_kind'>품종</div>
	<div class='board_list_subject'>제목</div>
	<div class='board_list_gender'>성별</div>
	<div class='board_list_locate'>지역</div>
	<div class='board_list_wdate'>게시일자</div>
	<div class='board_list_hits'>조회수</div>
</div>

<%
	for(int a=0; a<al.size(); a++){ 
	FmBoardVo v = al.get(a);
	String fini="";
	if(v.getFinish()!=null){
		if(v.getFinish().length()>3){
			fini="[분양완료]";
		}
	}
%>
<div class='board_list_items'>
	<div class='board_list_rno'><%=v.getRno() %></div>
	<div class='board_list_pic'>
	<%
	int d = v.getDeep().split("-").length;
	if(d==1){	
	if(v.getPic()!=null){ %><img src='./BoardPhoto/sm_<%=v.getPic() %>' align="middle" alt ='사진' width='80px' height='80px'>
	<%}else { %><img src='./FmBoard/noImg.png' align="middle" alt ='사진' width='80px' height='80px'><%} }%></div>
	<div class='board_list_kind'><%if(v.getKind()!=null){%><%=v.getKind() %><%} %></div>
	<div class='board_list_subject'>
		<a href='#' onclick='goView(<%=dto.getNowPage()%>,<%=v.getRno()%>)'>
		<%
		if(d > 1){
			for(int aa = 0; aa <d; aa++){
				out.print("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
			}
			out.print("┖");
		}
		
		%>
		
		<%=v.getSubject() %>&nbsp;&nbsp;<%=fini%>
		
		
	
		
		
		</a></div>
	<div class='board_list_gender'><%if(v.getGender()!=null){%><%=v.getGender()%><%} %></div>
	<div class='board_list_locate'><%if(v.getLocate()!=null){%><%=v.getLocate() %><%} %></div>
	<div class='board_list_wdate'><%if(v.getWdate()!=null){%><%=v.getWdate().substring(0,10)%><%} %></div>
	<div class='board_list_hits'><%=v.getHits() %></div>
</div>
<% }%>
<p/>
<div id='list_page'>
<%
int i = 0;%>

<a href='#' onclick='goPage(1)'>[맨앞]</a>

<%if(dto.getStartPage()!=1){%>

<a href='#' onclick='goPage(<%=dto.getStartPage()-1%>)'>[이전]</a>
 
<%}
for(i=dto.getStartPage(); i<=dto.getEndPage();i++){ 
	 if(dto.getNowPage() == i){%>
		<a href='#' onclick='goPage(<%=i%>)'><font size=4 color='#ff0000'><b>[<%=i %>]</b></font></a>
	<%}else{ %>
		<a href='#' onclick='goPage(<%=i%>)'>[<%=i %>]</a>
	<%} %>
<%} 
if(dto.getEndPage()!=dto.getTotPage()){%>

	<a href='#' onclick='goPage(<%=i %>)'>[다음]</a> <%} %>


<a href='#' onclick='goPage(<%=dto.getTotPage() %>)'>[맨끝]</a>
</div>




<script>bListInit();</script>
</body>
</html>